package com.forezp.examplerpcclient;


import com.netty.rpc.annotation.EnableNettyRpc;
import com.netty.rpc.common.dto.RespDTO;
import com.netty.rpc.config.NettyRpcProperties;
import com.netty.rpc.lib.IGreeting;
import com.netty.rpc.lib.bean.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
@EnableNettyRpc(basePackages = "com.netty.rpc.lib")
public class ExampleRpcClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(ExampleRpcClientApplication.class, args);
    }

    @Autowired
    NettyRpcProperties properties;

    @Autowired
    IGreeting greeting;

    // IGreeting invoker = (IGreeting) Invoker.invoke( IGreeting.class );
    //   Object result = invoker.sayHello( "sww" );

    @GetMapping("/test")
    public RespDTO test() throws Exception {
        String resuult = greeting.sayHello("miya");
        Person person=greeting.getPerson();
        return RespDTO.success(person);
    }
}
